package cz.muni.fi.hauntedhouses.util;

import cz.muni.fi.hauntedhouses.entity.Skill;
import cz.muni.fi.hauntedhouses.to.SkillTO;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Wendy
 */
public class SkillUtil {
    
     public static SkillTO toDTO(Skill skill) {
         if(skill==null){
         return null;
         }
        SkillTO skillTO = new SkillTO();
        skillTO.setId(skill.getId());                        
        skillTO.setName(skill.getName());
        skillTO.setCausesFear(skill.getCausesFear());
        skillTO.setDescription(skill.getDescription());
        skillTO.setPower(skill.getPower());
        return skillTO;
    }
    
    public static Skill toDAO(SkillTO skillTO) {
        if (skillTO == null) {
            return null;
        }
        
        Skill skill = new Skill();
        skill.setId(skillTO.getId());
        skill.setName(skillTO.getName());
        skill.setCausesFear(skillTO.getCausesFear());
        skill.setPower(skillTO.getPower());
        skill.setDescription(skillTO.getDescription());
                
        return skill;
    }
    
    public static List<SkillTO> listToDTO(List<Skill> list) {
        List<SkillTO> result = new ArrayList<SkillTO>();
        Iterator<Skill> listIterator = list.iterator(); 
        while (listIterator.hasNext()) {
            result.add(SkillUtil.toDTO(listIterator.next()));
        }
        
        return result;
        
    }
}


